package com.example.module_service.device

import android.os.Bundle
import androidx.activity.enableEdgeToEdge
import androidx.activity.viewModels
import androidx.appcompat.app.AppCompatActivity
import androidx.core.view.ViewCompat
import androidx.core.view.WindowInsetsCompat
import com.alibaba.android.arouter.facade.annotation.Autowired
import com.alibaba.android.arouter.facade.annotation.Route
import com.alibaba.android.arouter.launcher.ARouter
import com.example.lib_base.path.RouterPath
import com.example.lib_common.view.entity.DeviceDetailEntity
import com.example.lib_common.view.view.BaseMvvmActivity
import com.example.module_service.R
import com.example.module_service.adapter.ParkDetailAdapter

import com.example.module_service.databinding.ActivityDeviecdetatailBinding
import com.example.module_service.viewmodel.ServerViewModel
import dagger.hilt.android.AndroidEntryPoint

@AndroidEntryPoint
@Route(path = RouterPath.PATH_DEVICE_DETAIL_PAGE)
class DeviecdetatailActivity : BaseMvvmActivity<ActivityDeviecdetatailBinding>() {
    override fun getLayoutId(): Int =R.layout.activity_deviecdetatail



    //接收ARout传来的数值
    @Autowired
    @JvmField
    var id :Int=0


    private val mViewModel :ServerViewModel by viewModels()
    private lateinit var DeviceDetailAdapter: ParkDetailAdapter
    private val detaillist = mutableListOf<DeviceDetailEntity>()
    override fun initViews() {

        ARouter.getInstance().inject(this)
        DeviceDetailAdapter=ParkDetailAdapter(detaillist)
        mDataBinding.devicedetail.run {
            layoutManager = androidx.recyclerview.widget.LinearLayoutManager(this@DeviecdetatailActivity)
            adapter = DeviceDetailAdapter
        }

    }

    override fun loadData() {
        super.loadData()
        mViewModel.getDeviceDetail((id-20))
    }

    override fun observeDataChang() {
        super.observeDataChang()
        mViewModel.DeviceDetailSuccess.observe(this){
            // detaillist.clear()
            detaillist.addAll(it)
            DeviceDetailAdapter.notifyDataSetChanged()
        }
    }
    override fun getActivityState(state: Bundle) {

    }

    override fun saveActivityState(outState: Bundle) {

    }

}








